package com.yxw.yxnet_cd_center.customer_service.controller;

import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.helper.ResultHelper;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import com.yxw.yxnet_cd_center.customer_service.dto.ChannelStatisticsQueryDTO;
import com.yxw.yxnet_cd_center.customer_service.dto.ExportChannelStatisticsDTO;
import com.yxw.yxnet_cd_center.customer_service.service.ChannelStatisticsService;
import com.yxw.yxnet_cd_center.customer_service.vo.ChannelStatisticsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @author fangmaoxin
 * @version 1.0
 * @date 2023年9月19日
 * 渠道活跃度统计-控制层
 */
@RestController
@Api(value = "渠道活跃度统计管理", tags = "渠道活跃度管理")
@Slf4j
@RequestMapping("/channel_statistics/v1")
public class ChannelStatisticsController {

    @Autowired
    private ChannelStatisticsService channelStatisticsService;


    /**
     * 查询渠道活跃度统计列表
     */
    @PostMapping("/list")
    @ApiOperation(value = "查询渠道活跃度统计列表")
    public BaseResult<PageVO<ChannelStatisticsVo>> list(@RequestBody ChannelStatisticsQueryDTO dto) {
        PageVO<ChannelStatisticsVo> channelStatisticsList = channelStatisticsService.selectChannelStatisticsList(dto);
        return ResultHelper.fillWithSuccess(channelStatisticsList);
    }

    /**
     * 导出数据
     */
    @PostMapping("/exportExcel")
    @ApiOperation(value = "导出渠道活跃管理数据")
    public void exportExcel(HttpServletResponse response, @RequestBody ExportChannelStatisticsDTO dto) {
        channelStatisticsService.exportExcel(response, dto);
    }

    /**
     * 进行渠道活跃统计
     */
    @PostMapping("/channelStatistics")
    @ApiOperation(value = "进行渠道活跃统计")
    public BaseResult insertChannelStatistics() {
        channelStatisticsService.insertChannelStatistics();
        return BaseResult.doSuccess(null,"进行渠道活跃统计成功");
    }

}
